package com.xiongwei.springcloud.service;

import com.xiongwei.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author XiongWei
 * @date 2021/8/22
 */
@Component
public class DeptClientServiceFailbackFactory implements FallbackFactory<DeptClientService> {

    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {

            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public Dept get(Long id) {
                return new Dept().setDeptNo(id)
                        .setDname("没有对应信息，此服务已降级")
                        .setDb_source("no database info");
            }
        };
    }
}
